package com.my.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer{
  String path = System.getProperty("user.dir").replace("\\","/");
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    //文件磁盘图片url 映射
    //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
    //配置静态文件路径，与上面并不冲突
    registry.addResourceHandler("/").addResourceLocations("classpath:/META-INF/resources/public/");
    registry.addResourceHandler("/family_archives/**").addResourceLocations("file:"+path+"/family_archives/");
    registry.addResourceHandler("/picture/**").addResourceLocations("file:"+path+"/picture/");

  }
}
